package com.sc.nft.util;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import lombok.experimental.UtilityClass;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

@UtilityClass
public class OrderNoUtil {

    public static final String SETTLE_ORDER_PREFIX = "C01";
    public static final String SPLIT_ORDER_PREFIX = "S01";



    /**
     * 获取订单编号
     * @param
     * @param
     * @return
     */
    public String  getOrderNo(){
        StringBuffer sb = new StringBuffer();
        sb.append(DateUtil.format(DateTime.now(),"yyyyMMddHHmmssSSS"));
        sb.append(RandomUtil.randomInt(100000,999999));
        return sb.toString();
    }

    public String  getOrderNo(String orderType ){
        StringBuffer sb = new StringBuffer();
        sb.append(DateUtil.format(DateTime.now(),"yyyyMMddHHmmssSSS"));
        sb.append(orderType);
        sb.append(RandomUtil.randomInt(100000,999999));
        return sb.toString();
    }

    /**
     * 通用订单号生成器 前缀拼接方式
     * @param prefix
     * @return
     */
    public String getOrderSn(String prefix){
        StringBuffer sb = new StringBuffer();
        sb.append(prefix);
        sb.append(RandomUtil.randomInt(100000,999999));
        sb.append(DateUtil.format(DateTime.now(),"yyyyMMddHHmmssSSS"));
        return sb.toString();
    }

}
